;;;SHOW_LOG Shows Drawing log (EED) PRINTLOG to print.  (uses LOG_IT to make log)
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
;;;****************************************************************************
(defun c:show_log (/)
  (setq rapnm "CORP")
  (regapp rapnm)
  (setq edss (ssget "x" (list '(-3 ("CORP")) (cons 2 "DWG-EDIT-LOG"))))
  (IF vlax-ldata-get NIL (VL-LOAD-COM))
  (cond
    (edss
      (setq ename (ssname edss 0))
      (setq xelst (entget ename (list rapnm)))
      (setq xedlst (cdadr(assoc -3 xelst)))
      (foreach n xedlst
        (IF (EQUAL n (CONS 1002 "}"))
          (PRINC
            log_line
          )
          (IF (EQUAL n (CONS 1002 "{"))
            (SETQ log_line "\n\t")
            (SETQ log_line (strcat log_line (CDR n) " "))
          )
        )
      ))
     ((setq logit_ldata (vlax-ldata-get "logit_data" "dwgedit_data"))
       (MAPCAR '(LAMBDA (x) (PRINC "\n")(MAPCAR '(LAMBDA (y) (PRINC "\n")(PRINC (CAR y))(PRINC ": ")(PRINC (CDR y))(PRINC " ")) x)) logit_ldata))
     (T (princ "\nDrawing Edit Log is not available. "))
  )
(princ)
)
;;;****************************************************************************
(defun c:printlog (/)
  (setq rapnm "CORP")
  (regapp rapnm)
  (if
    (=(substr (setq curdwg (getvar"dwgname")) 2 1)":")
    (progn
      (setq cdstrl (strlen curdwg))
      (while
        (not(=(substr curdwg (1- cdstrl) 1)"\\"))
        (setq cdstrl (1- cdstrl))
      )
      (setq curdwg (strcase(substr curdwg cdstrl)))
    );progn
  );if
  (setq lf1 (open "lpt1" "w"))
  (cond
    ((setq edss (ssget "x" (list '(-3 ("CORP")) (cons 2 "DWG-EDIT-LOG")(cons 10 (list 0.0 0.0 0.0)))))
      (write-line (getvar"dwgname") lf1)
      (setq ename (ssname edss 0))
      (setq xelst (entget ename (list rapnm)))
      (setq xedlst (cdr(reverse(cddr(assoc rapnm(cdr(assoc -3 xelst)))))))
      (foreach n xedlst
        (progn
          (cond ((eq(substr(cdr n)1 1)"O")
                 (setq actstr "Opened By: "))
                ((eq(substr(cdr n)1 1)"P")
                 (setq actstr "Printed By: "))
                ((eq(substr(cdr n)1 1)"J")
                 (setq actstr "Plotted By: "))
                ((eq(substr(cdr n)1 1)"C")
                 (setq actstr "Closed By: "))
          )
          (write-line
            (strcat
              actstr(substr(cdr n)13 3)" as: "(substr(cdr n)16)" on: "(substr(cdr n)4 2)"-"
              (substr(cdr n)6 2)"-"(substr(cdr n)2 2)" at: "(substr(cdr n)9 2)":"(substr(cdr n)11 2)
            )
          lf1)
        )
      ))
     ((setq logit_ldata (vlax-ldata-get "logit_data" "dwgedit_data"))
       (MAPCAR '(LAMBDA (x) (WRITE-LINE
                              (STRCAT
                                (CDR (ASSOC "Action" x)) " as: "
                                (CDR (ASSOC "Location" x))
                                (CDR (ASSOC "Drawing" x)) " by: "
                                (CDR (ASSOC "Username" x)) " at: "
                                (CDR (ASSOC "Workstation" x)) " on: "
                                (CDR (ASSOC "Date" x))
                              )
                              lf1
                            )
                )
               logit_ldata
       ))
    (T (write-line "No Log found. " lf1))
  )
(if lf1 (close lf1))
(princ)
)
;;;****************************************************************************
(defun c:writelog (/)
  (setq rapnm "CORP")
  (regapp rapnm)
  (if
    (=(substr (setq curdwg (getvar"dwgname")) 2 1)":")
    (progn
      (setq cdstrl (strlen curdwg))
      (while
        (not(=(substr curdwg (1- cdstrl) 1)"\\"))
        (setq cdstrl (1- cdstrl))
      )
      (setq curdwg (strcase(substr curdwg cdstrl)))
    );progn
  );if
  (setq lf1 (open(strcat curdwg ".log") "w"))
  (if
    (setq edss (ssget "x" (list '(-3 ("CORP")) (cons 2 "DWG-EDIT-LOG")(cons 10 (list 0.0 0.0 0.0)))))
    (progn
      (write-line (getvar"dwgname") lf1)
      (setq ename (ssname edss 0))
      (setq xelst (entget ename (list rapnm)))
      (setq xedlst (cdr(reverse(cddr(assoc rapnm(cdr(assoc -3 xelst)))))))
      (foreach n xedlst
        (progn
          (cond ((eq(substr(cdr n)1 1)"O")
                 (setq actstr "\nOpened By: "))
                ((eq(substr(cdr n)1 1)"P")
                 (setq actstr "\nPrinted By: "))
                ((eq(substr(cdr n)1 1)"J")
                 (setq actstr "\nPlotted By: "))
                ((eq(substr(cdr n)1 1)"C")
                 (setq actstr "\nClosed By: "))
          )
          (write-line
            (strcat
              actstr(substr(cdr n)13 3)" as: "(substr(cdr n)16)" on: "(substr(cdr n)4 2)"-"
              (substr(cdr n)6 2)"-"(substr(cdr n)2 2)" at: "(substr(cdr n)9 2)":"(substr(cdr n)11 2)
            )
          lf1)
        )
      )
    );progn
    (write-line "Log is not available. " lf1)
  );if
(if lf1 (close lf1))
(princ)
)
;;;****************************************************************************
(princ)